package com.wbcs.jbsf.auth.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.wbcs.jbsf.auth.abs.AbstandLogin;
import com.wbcs.jbsf.auth.abs.impl.CommonLogin;
import com.wbcs.jbsf.util.Wbcs4JBSFUtil;

/**
 * JBSF权限总控器
 * @author hawkfly
 */
public class AjaxLoginServlet extends HttpServlet
{
    private static final long serialVersionUID=-1749357115876085600L;
    
    @Override
	public void init(ServletConfig config) throws ServletException {
    }
    
    @Override
	public void service(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
        PrintWriter out = response.getWriter();
        String msg = "";
		try {
			msg = new CommonLogin(request, response).addRequestStatus(AbstandLogin.RequestStatus.ajax).doLogin();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        //用户名或密码错误
        if(!Wbcs4JBSFUtil.isOk(msg))out.write(msg);
        out.close();
    }
}